/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View, Navigator
} from 'react-native';
import TestBleManager from "./app/TestBleManager";
export default class TestMyNpm extends Component {
    static propTypes = {
        navigator: React.PropTypes.object.isRequired,
    };

    test_TestBleManager() {
        const {navigator} = this.props;

        if (navigator) {
            navigator.push({
                name: "TestBleManager",
                component: TestBleManager,
            });
        } else {
            alert(navigator);
        }
    }

    render() {
        return (
            <Text onPress={this.test_TestBleManager.bind(this)}
                  style={styles.testSize}>
                TextProtoManager
            </Text>
        );
    }
}
/**
 * 构建一个component 用来当程序入口
 * 注意，需要在程序入口保存适当内容，用于后续比如跳转界面等，如以下的navigator是跳转必须的
 */
class Start extends Component {
    render() {
        var defaultName = 'TestMyNpm';
        var defaultComponent = TestMyNpm;
        return (
            <Navigator
                //指定了默认的页面，也就是启动app之后会看到的第一屏，需要两个参数，name跟component
                initialRoute={{ name: defaultName, component: defaultComponent }}
                configureScene={
                    (route) => {
                                      //跳转的动画
                                      return Navigator.SceneConfigs.FloatFromLeft;
                    }
                }
                renderScene={
                    (route, navigator) => {
                                      let Component = route.component;
                                      if(route.component){
                                              return <Component {...route.params} navigator={navigator} />
                                      }
                    }
                }
            />
        );
    }
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
    testSize: {
        margin: 5,
        backgroundColor: '#dddddd',
        fontSize: 18,
        padding: 20,
    }
});

AppRegistry.registerComponent('TestMyNpm', () => Start);
